package top.lingkang.authoritypro.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.lingkang.authoritypro.data.dto.ResponseResult;
import top.lingkang.authoritypro.data.pojo.UserDetails;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lingkang
 * Created by 2021/12/14
 */

@Controller
@RequestMapping("auth")
public class AuthController {
    @Autowired
    private HttpServletRequest request;

    @GetMapping("login")
    public String login() {
        return "login";
    }

    @GetMapping("menu")
    @ResponseBody
    public Object menu(){
        UserDetails userDetails = (UserDetails) request.getSession().getAttribute("user");
        return new ResponseResult<>().success(userDetails.getMenus());
    }
}
